import marketingApi from '@/config/server/api/marketing'
import baseApi from '@/config/server/api/base'

//公司列表
function companyPage(params) {
  return marketingApi.companyCard.companyPage.fetch(params)
}
//根据id查询公司
function companygetByOrgId(params) {
  return marketingApi.companyCard.companygetByOrgId.fetch(params)
}
//编辑公司
function companyUpdate(params) {
  return marketingApi.companyCard.companyUpdate.fetch(params)
}
//根据id查询名片
function getByUserCardAuditId(params) {
  return marketingApi.companyCard.getByUserCardAuditId.fetch(params)
}
//创建公司
function companyCreate(params) {
  return marketingApi.companyCard.companyCreate.fetch(params)
}

//根据id查询公司
function getByCompanyId(params) {
  return marketingApi.companyCard.getByCompanyId.fetch(params)
}

//修改公司简介
function updateCompanyIntroduction(params) {
  return marketingApi.companyCard.updateCompanyIntroduction.fetch(params)
}

//修改启用状态
function updateEnableStatus(params) {
  return marketingApi.companyCard.updateEnableStatus.fetch(params)
}

//分页查询公司服务信息
function companyServicePage(params) {
  return marketingApi.companyCard.companyServicePage.fetch(params)
}

//创建公司服务
function companyServiceCreate(params) {
  return marketingApi.companyCard.companyServiceCreate.fetch(params)
}

//删除公司服务
function companyServiceDel(params) {
  return marketingApi.companyCard.companyServiceDel.fetch(params)
}

//编辑公司服务
function companyServiceUpdate(params) {
  return marketingApi.companyCard.companyServiceUpdate.fetch(params)
}

//更新排序及显示
function updateDisplayAndSort(params) {
  return marketingApi.companyCard.updateDisplayAndSort.fetch(params)
}

//小程序二维码
function getwxCodeUserCard(params) {
  return marketingApi.companyCard.getwxCodeUserCard.fetch(params).then(res => {
    let base64 = 'data:image/png;base64,' + res
    return base64
  })
}

//根据id查询公司服务排序规则数据
function companyServiceSortList(params) {
  return marketingApi.companyCard.companyServiceSortList.fetch(params).then(res => {
    res && res.displayCompanyServiceList.forEach(item => {
      item.dbkey = item.id;
      item.fieldValue = item.serviceTitle
    });
    res && res.unDisplayCompanyServiceList.forEach(item => {
      item.dbkey = item.id;
      item.fieldValue = item.serviceTitle
    });
    return res
  })
}

//名片创建记录api
function userCardCreatePage(params) {
  return marketingApi.companyCard.companyCardLog.userCardCreatePage.fetch(params)
}

//名片创建记录导出
function userCardExport(params) {
  return marketingApi.companyCard.companyCardLog.userCardExport.fetch(params)
}

//删除名片
function userCardDelete(params) {
  return marketingApi.companyCard.companyCardLog.userCardDelete.fetch(params)
}


export default {
  companyPage,
  companyUpdate,
  companygetByOrgId,
  getByUserCardAuditId,
  companyCreate,
  getByCompanyId,
  updateCompanyIntroduction,
  updateEnableStatus,
  companyServicePage,
  companyServiceCreate,
  companyServiceDel,
  companyServiceUpdate,
  updateDisplayAndSort,
  getwxCodeUserCard,
  companyServiceSortList,
  userCardCreatePage,
  userCardExport,
  userCardDelete,
}